package com.cyzy.controller;

import com.cyzy.dto.Result;
import com.cyzy.pojo.LikeRecord;
import com.cyzy.service.ArtGalleryService;
import com.cyzy.vo.CampusWorks;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description: 美术馆控制层
 * @author: yangJingShi
 * @date: 2025/6/13 上午8:57
 * @param:
 * @return:
 **/
@RestController
@RequestMapping("/artGallery")
public class ArtGalleryController {

    @Autowired
    private ArtGalleryService artGalleryService;

    /**|
     * 查询用户所在的校区ID作品（图片，作品名，作者，班级）
     * @param campusId
     * @return
     */
    @GetMapping("/getAllArtList")
    public Result getAllArtList(@RequestParam("campusId") Long campusId,
                                @RequestParam("parentId") Long parentId,
                                @RequestParam("teacherId") Long teacherId){
        List<CampusWorks> artworkInfoList = artGalleryService.getArtworkInfoListByTeacher(campusId, teacherId, parentId);
        return Result.ok().message("查询艺术家作品列表").data("artworkInfoList",artworkInfoList);
    }

    @PostMapping("/userLikeArt")
    public Result userLikeArt(@RequestBody LikeRecord likeRecord){
        Boolean b = artGalleryService.UserChangeLikes(likeRecord);
        if (b){
            return Result.ok().message("投票成功");
        }else {
            return Result.ok().message("投票失败");
        }

    }
}
